

<!DOCTYPE html>

<html>
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>How To Build On ARM &#8212; LLVM 9 documentation</title>
    <link rel="stylesheet" href="_static/llvm-theme.css" type="text/css" />
    <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
    <script id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
    <script src="_static/jquery.js"></script>
    <script src="_static/underscore.js"></script>
    <script src="_static/doctools.js"></script>
    <script src="_static/language_data.js"></script>
    <link rel="index" title="Index" href="genindex.html" />
    <link rel="search" title="Search" href="search.html" />
    <link rel="next" title="How To Build Clang and LLVM with Profile-Guided Optimizations" href="HowToBuildWithPGO.html" />
    <link rel="prev" title="Advanced Build Configurations" href="AdvancedBuilds.html" />
<style type="text/css">
  table.right { float: right; margin-left: 20px; }
  table.right td { border: 1px solid #ccc; }
</style>

  </head><body>
<div class="logo">
  <a href="index.html">
    <img src="_static/logo.png"
         alt="LLVM Logo" width="250" height="88"/></a>
</div>

    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="HowToBuildWithPGO.html" title="How To Build Clang and LLVM with Profile-Guided Optimizations"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="AdvancedBuilds.html" title="Advanced Build Configurations"
             accesskey="P">previous</a> |</li>
  <li><a href="http://llvm.org/">LLVM Home</a>&nbsp;|&nbsp;</li>
  <li><a href="index.html">Documentation</a>&raquo;</li>

        <li class="nav-item nav-item-this"><a href="">How To Build On ARM</a></li> 
      </ul>
    </div>


    <div class="document">
      <div class="documentwrapper">
          <div class="body" role="main">
            
  <div class="section" id="how-to-build-on-arm">
<h1>How To Build On ARM<a class="headerlink" href="#how-to-build-on-arm" title="Permalink to this headline">¶</a></h1>
<div class="section" id="introduction">
<h2>Introduction<a class="headerlink" href="#introduction" title="Permalink to this headline">¶</a></h2>
<p>This document contains information about building/testing LLVM and
Clang on an ARM machine.</p>
<p>This document is <em>NOT</em> tailored to help you cross-compile LLVM/Clang
to ARM on another architecture, for example an x86_64 machine. To find
out more about cross-compiling, please check <a class="reference internal" href="HowToCrossCompileLLVM.html"><span class="doc">How To Cross-Compile Clang/LLVM using Clang/LLVM</span></a>.</p>
</div>
<div class="section" id="notes-on-building-llvm-clang-on-arm">
<h2>Notes On Building LLVM/Clang on ARM<a class="headerlink" href="#notes-on-building-llvm-clang-on-arm" title="Permalink to this headline">¶</a></h2>
<p>Here are some notes on building/testing LLVM/Clang on ARM. Note that
ARM encompasses a wide variety of CPUs; this advice is primarily based
on the ARMv6 and ARMv7 architectures and may be inapplicable to older chips.</p>
<ol class="arabic">
<li><p>The most popular Linaro/Ubuntu OS’s for ARM boards, e.g., the
Pandaboard, have become hard-float platforms. There are a number of
choices when using CMake. Autoconf usage is deprecated as of 3.8.</p>
<p>Building LLVM/Clang in <code class="docutils literal notranslate"><span class="pre">Relese</span></code> mode is preferred since it consumes
a lot less memory. Otherwise, the building process will very likely
fail due to insufficient memory. It’s also a lot quicker to only build
the relevant back-ends (ARM and AArch64), since it’s very unlikely that
you’ll use an ARM board to cross-compile to other arches. If you’re
running Compiler-RT tests, also include the x86 back-end, or some tests
will fail.</p>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>cmake <span class="nv">$LLVM_SRC_DIR</span> -DCMAKE_BUILD_TYPE<span class="o">=</span>Release <span class="se">\</span>
                    -DLLVM_TARGETS_TO_BUILD<span class="o">=</span><span class="s2">&quot;ARM;X86;AArch64&quot;</span>
</pre></div>
</div>
<p>Other options you can use are:</p>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>Use Ninja instead of Make: <span class="s2">&quot;-G Ninja&quot;</span>
Build with assertions on: <span class="s2">&quot;-DLLVM_ENABLE_ASSERTIONS=True&quot;</span>
Force Python2: <span class="s2">&quot;-DPYTHON_EXECUTABLE=/usr/bin/python2&quot;</span>
Local <span class="o">(</span>non-sudo<span class="o">)</span> install path: <span class="s2">&quot;-DCMAKE_INSTALL_PREFIX=</span><span class="nv">$HOME</span><span class="s2">/llvm/instal&quot;</span>
CPU flags: <span class="s2">&quot;DCMAKE_C_FLAGS=-mcpu=cortex-a15&quot;</span> <span class="o">(</span>same <span class="k">for</span> CXX_FLAGS<span class="o">)</span>
</pre></div>
</div>
<p>After that, just typing <code class="docutils literal notranslate"><span class="pre">make</span> <span class="pre">-jN</span></code> or <code class="docutils literal notranslate"><span class="pre">ninja</span></code> will build everything.
<code class="docutils literal notranslate"><span class="pre">make</span> <span class="pre">-jN</span> <span class="pre">check-all</span></code> or <code class="docutils literal notranslate"><span class="pre">ninja</span> <span class="pre">check-all</span></code> will run all compiler tests. For
running the test suite, please refer to <a class="reference internal" href="TestingGuide.html"><span class="doc">LLVM Testing Infrastructure Guide</span></a>.</p>
</li>
<li><p>If you are building LLVM/Clang on an ARM board with 1G of memory or less,
please use <code class="docutils literal notranslate"><span class="pre">gold</span></code> rather then GNU <code class="docutils literal notranslate"><span class="pre">ld</span></code>. In any case it is probably a good
idea to set up a swap partition, too.</p>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>$ sudo ln -sf /usr/bin/ld /usr/bin/ld.gold
</pre></div>
</div>
</li>
<li><p>ARM development boards can be unstable and you may experience that cores
are disappearing, caches being flushed on every big.LITTLE switch, and
other similar issues.  To help ease the effect of this, set the Linux
scheduler to “performance” on <strong>all</strong> cores using this little script:</p>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span><span class="c1"># The code below requires the package &#39;cpufrequtils&#39; to be installed.</span>
<span class="k">for</span> <span class="o">((</span><span class="nv">cpu</span><span class="o">=</span><span class="m">0</span><span class="p">;</span> cpu&lt;<span class="sb">`</span>grep -c proc /proc/cpuinfo<span class="sb">`</span><span class="p">;</span> cpu++<span class="o">))</span><span class="p">;</span> <span class="k">do</span>
    sudo cpufreq-set -c <span class="nv">$cpu</span> -g performance
<span class="k">done</span>
</pre></div>
</div>
<p>Remember to turn that off after the build, or you may risk burning your
CPU. Most modern kernels don’t need that, so only use it if you have
problems.</p>
</li>
<li><p>Running the build on SD cards is ok, but they are more prone to failures
than good quality USB sticks, and those are more prone to failures than
external hard-drives (those are also a lot faster). So, at least, you
should consider to buy a fast USB stick.  On systems with a fast eMMC,
that’s a good option too.</p></li>
<li><p>Make sure you have a decent power supply (dozens of dollars worth) that can
provide <em>at least</em> 4 amperes, this is especially important if you use USB
devices with your board. Externally powered USB/SATA harddrives are even
better than having a good power supply.</p></li>
</ol>
</div>
</div>


            <div class="clearer"></div>
          </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="HowToBuildWithPGO.html" title="How To Build Clang and LLVM with Profile-Guided Optimizations"
             >next</a> |</li>
        <li class="right" >
          <a href="AdvancedBuilds.html" title="Advanced Build Configurations"
             >previous</a> |</li>
  <li><a href="http://llvm.org/">LLVM Home</a>&nbsp;|&nbsp;</li>
  <li><a href="index.html">Documentation</a>&raquo;</li>

        <li class="nav-item nav-item-this"><a href="">How To Build On ARM</a></li> 
      </ul>
    </div>
    <div class="footer" role="contentinfo">
        &#169; Copyright 2003-2020, LLVM Project.
      Last updated on 2020-09-20.
      Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 3.2.1.
    </div>
  </body>
</html>